package com.hy.controller;

import com.hy.Vo.ExamineFlowDetailPurchaseApplyVo;
import com.hy.bean.ExamineFlowDetail;
import com.hy.bean.RespBean;
import com.hy.service.ExamineFlowDetailService;
import com.hy.service.impl.ExamineFlowDetailServiceImpl;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * (ExamineFlowDetail)表控制层
 *
 * @author makejava
 * @since 2024-04-29 16:36:06
 */
@RestController
@RequestMapping("examineFlowDetail")
public class ExamineFlowDetailController {
    /**
     * 服务对象
     */

    private ExamineFlowDetailService examineFlowDetailService = new ExamineFlowDetailServiceImpl();

    private Logger logger = LoggerFactory.getLogger(this.getClass());
    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
//    @GetMapping("{id}")
//    public ResponseEntity<ExamineFlowDetail> queryById(@PathVariable("id") int id) {
//        return ResponseEntity.ok(this.examineFlowDetailService.queryExamineById(id));
//    }

    @GetMapping("query/{id}")
    public ExamineFlowDetailPurchaseApplyVo queryExamineById(@PathVariable("id") Integer id){
        return examineFlowDetailService.queryExamineById(id);
    }

    @GetMapping("listAll/{status}")
    public List<ExamineFlowDetailPurchaseApplyVo> listAll(@PathVariable("status") Integer status){
        return examineFlowDetailService.listAll(status);
    }

    /**
     * 新增数据
     *
     * @param title 标题
     * @param status 标题
     * @param padId 购买申请id
     * @return 新增结果
     */
    @PostMapping("add")
    public RespBean add(String title,Integer status,Integer padId) {
        return examineFlowDetailService.insert(title,status,padId);
    }

    /**
     * 编辑数据
     *
     * @param examineFlowDetail 实体
     * @return 编辑结果
     */
    @PutMapping("update")
    public RespBean edit(@RequestBody ExamineFlowDetail examineFlowDetail) {
        return examineFlowDetailService.update(examineFlowDetail);
    }

    /**
     * 删除数据
     *
     * @param id 主键
     * @return 删除是否成功
     */
    @DeleteMapping
    public ResponseEntity<Boolean> deleteById(int id) {
        return ResponseEntity.ok(this.examineFlowDetailService.deleteById(id));
    }

}

